<html>
<head><meta charset="utf-8"><title>negative impls integrated into coherence lang-team#96 · t-lang/major changes · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/index.html">t-lang/major changes</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/negative.20impls.20integrated.20into.20coherence.20lang-team.2396.html">negative impls integrated into coherence lang-team#96</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="241076910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/negative%20impls%20integrated%20into%20coherence%20lang-team%2396/near/241076910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> triagebot <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/negative.20impls.20integrated.20into.20coherence.20lang-team.2396.html#241076910">(Jun 01 2021 at 21:16)</a>:</h4>
<p>A new proposal has been announced: <a href="https://github.com/rust-lang/lang-team/issues/96">negative impls integrated into coherence #96</a>. It will be announced at the next meeting to try and draw attention to it, but usually MCPs are not discussed during triage meetings. If you think this would benefit from discussion amongst the team, consider proposing a design meeting.</p>



<a name="241375632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/negative%20impls%20integrated%20into%20coherence%20lang-team%2396/near/241375632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/negative.20impls.20integrated.20into.20coherence.20lang-team.2396.html#241375632">(Jun 03 2021 at 11:06)</a>:</h4>
<blockquote>
<p>Note that this would not permit where T: !Trait syntax, although we could in principle support that, though we would have to be careful about what it means (in particular, it would be relatively easy to support if what it means is "there is a negative impl").</p>
</blockquote>
<p>I find it hard to imagine we could ever support any other meaning for this syntax. The meaning we assign to it has to be "stable under future worlds" where more impls are added, which checking for a negative impls is but checking for a lack of a positive impl is not.</p>



<a name="241376065"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/negative%20impls%20integrated%20into%20coherence%20lang-team%2396/near/241376065" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/negative.20impls.20integrated.20into.20coherence.20lang-team.2396.html#241376065">(Jun 03 2021 at 11:12)</a>:</h4>
<p>there are some contexts where we can reason about the full set of impls, for example when the type and the trait are private. (There is some discussion of this linked from the chalk readme.) In such cases the lack of an impl is enough to derive a negative impl fact</p>



<a name="241376220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/negative%20impls%20integrated%20into%20coherence%20lang-team%2396/near/241376220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/negative.20impls.20integrated.20into.20coherence.20lang-team.2396.html#241376220">(Jun 03 2021 at 11:13)</a>:</h4>
<p>That seems not obvious to me. Even private types &amp; traits can have impls depending on other public traits/types.</p>



<a name="241377556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/negative%20impls%20integrated%20into%20coherence%20lang-team%2396/near/241377556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/negative.20impls.20integrated.20into.20coherence.20lang-team.2396.html#241377556">(Jun 03 2021 at 11:29)</a>:</h4>
<p>I will defer to the chalk folks for what the actual rules are for deriving negative impl facts. (I'm thinking of <a href="https://aturon.github.io/blog/2017/04/24/negative-chalk/">this blog post</a> in particular.) But whatever the rules are, I would expect <code>T: !Trait</code> to be valid only when such a negative impl fact has been derived, whether that is due to non-impl combined with some kind of closed-world context, or an actual <code>!Trait</code> impl if/when that becomes an actual possibility.</p>



<a name="241388566"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/negative%20impls%20integrated%20into%20coherence%20lang-team%2396/near/241388566" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/negative.20impls.20integrated.20into.20coherence.20lang-team.2396.html#241388566">(Jun 03 2021 at 13:15)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> the meaning I wuld assign is:</p>



<a name="241388576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/negative%20impls%20integrated%20into%20coherence%20lang-team%2396/near/241388576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/negative.20impls.20integrated.20into.20coherence.20lang-team.2396.html#241388576">(Jun 03 2021 at 13:15)</a>:</h4>
<p>"there is a negative impl"</p>



<a name="241388592"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/negative%20impls%20integrated%20into%20coherence%20lang-team%2396/near/241388592" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/negative.20impls.20integrated.20into.20coherence.20lang-team.2396.html#241388592">(Jun 03 2021 at 13:15)</a>:</h4>
<p>I would not want to make it mean "there is no positive impl"</p>



<a name="241388598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/negative%20impls%20integrated%20into%20coherence%20lang-team%2396/near/241388598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/negative.20impls.20integrated.20into.20coherence.20lang-team.2396.html#241388598">(Jun 03 2021 at 13:15)</a>:</h4>
<p>for a variety of reasons</p>



<a name="241388720"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/negative%20impls%20integrated%20into%20coherence%20lang-team%2396/near/241388720" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/negative.20impls.20integrated.20into.20coherence.20lang-team.2396.html#241388720">(Jun 03 2021 at 13:16)</a>:</h4>
<p>one question I do have, though, is whether to tie it to the "coherence rules", i.e., to permit you to use the lack of positive impls as evidence, but I'd rather not, it makes the solver rather more complicated, and I'd prefer to phase those rules out in favor of explicit negative impls anyhow</p>



<a name="241388757"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/negative%20impls%20integrated%20into%20coherence%20lang-team%2396/near/241388757" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/negative.20impls.20integrated.20into.20coherence.20lang-team.2396.html#241388757">(Jun 03 2021 at 13:16)</a>:</h4>
<p>I suppose that could be a good goal to work towards for Rust 2024</p>



<a name="241390251"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/negative%20impls%20integrated%20into%20coherence%20lang-team%2396/near/241390251" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/negative.20impls.20integrated.20into.20coherence.20lang-team.2396.html#241390251">(Jun 03 2021 at 13:29)</a>:</h4>
<p>sounds reasonable, yeah</p>



<a name="241952398"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/negative%20impls%20integrated%20into%20coherence%20lang-team%2396/near/241952398" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> triagebot <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/negative.20impls.20integrated.20into.20coherence.20lang-team.2396.html#241952398">(Jun 08 2021 at 17:03)</a>:</h4>
<p><span class="user-group-mention" data-user-group-id="1977">@T-lang</span>: Proposal <a href="https://github.com/rust-lang/lang-team/issues/96#issuecomment-856939701">#96</a> has been seconded, and will be approved in 10 days if no objections are raised.</p>



<a name="241955311"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/negative%20impls%20integrated%20into%20coherence%20lang-team%2396/near/241955311" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> comex <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/negative.20impls.20integrated.20into.20coherence.20lang-team.2396.html#241955311">(Jun 08 2021 at 17:20)</a>:</h4>
<p>Deriving negative impl facts from the lack of an impl is potentially dangerous.  If combined with <code>T: !Trait</code>, it could allow nonoverlapping impls for types that differ only in lifetimes:</p>
<div class="codehilite"><pre><span></span><code>trait Static {}
impl Static for &amp;&#39;static () {}

trait Trait { type Assoc; }
impl&lt;T: !Static&gt; Trait for T { type Assoc = i64; }
impl Trait for &amp;&#39;static () { type Assoc = i32; }
</code></pre></div>



<a name="241957167"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/negative%20impls%20integrated%20into%20coherence%20lang-team%2396/near/241957167" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/negative.20impls.20integrated.20into.20coherence.20lang-team.2396.html#241957167">(Jun 08 2021 at 17:34)</a>:</h4>
<p><span class="user-mention" data-user-id="198590">@comex</span> My understanding of this previous comment <a href="#narrow/stream/243200-t-lang.2Fmajor-changes/topic/negative.20impls.20integrated.20into.20coherence.20lang-team.2396/near/241388592">https://rust-lang.zulipchat.com/#narrow/stream/243200-t-lang.2Fmajor-changes/topic/negative.20impls.20integrated.20into.20coherence.20lang-team.2396/near/241388592</a> is that "lack of an impl" would <em>not</em> derive a negative impl fact.</p>



<a name="241961383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/negative%20impls%20integrated%20into%20coherence%20lang-team%2396/near/241961383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/negative.20impls.20integrated.20into.20coherence.20lang-team.2396.html#241961383">(Jun 08 2021 at 18:04)</a>:</h4>
<p>Right. I think the point of <code>impl !Trait for SomeType</code> is specifically to allow people to depend on "there is not an implementation of Trait for SomeType", whereas if there just isn't an impl you <em>can't</em> rely on that not changing in the future.</p>



<a name="241963098"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/negative%20impls%20integrated%20into%20coherence%20lang-team%2396/near/241963098" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/negative.20impls.20integrated.20into.20coherence.20lang-team.2396.html#241963098">(Jun 08 2021 at 18:16)</a>:</h4>
<p>(I wonder if this could get to the point where <code>Copy =&gt; !Drop</code> &amp; <code>Drop =&gt; !Copy</code> could be library rules, rather than language magic.  Definitely not part of v1, though.)</p>



<a name="241969076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/negative%20impls%20integrated%20into%20coherence%20lang-team%2396/near/241969076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/negative.20impls.20integrated.20into.20coherence.20lang-team.2396.html#241969076">(Jun 08 2021 at 18:59)</a>:</h4>
<p><span class="user-mention" data-user-id="125270">@scottmcm</span> I wonder as well whether we might one day be able to define some useful rule akin to <code>!Drop =&gt; Copy</code>.</p>



<a name="241970071"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/negative%20impls%20integrated%20into%20coherence%20lang-team%2396/near/241970071" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Connor Horman <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/negative.20impls.20integrated.20into.20coherence.20lang-team.2396.html#241970071">(Jun 08 2021 at 19:06)</a>:</h4>
<p>I don't think that<code>!Drop =&gt; Copy</code> holds (or could hold), though.  It can be invalid to copy types even if they promise not to have a destructor.</p>



<a name="241979618"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/negative%20impls%20integrated%20into%20coherence%20lang-team%2396/near/241979618" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/negative.20impls.20integrated.20into.20coherence.20lang-team.2396.html#241979618">(Jun 08 2021 at 20:15)</a>:</h4>
<p>"some useful rule akin to", not necessarily that rule. It seems like there's a useful property that holds, somehow.</p>



<a name="241979641"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/negative%20impls%20integrated%20into%20coherence%20lang-team%2396/near/241979641" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/negative.20impls.20integrated.20into.20coherence.20lang-team.2396.html#241979641">(Jun 08 2021 at 20:15)</a>:</h4>
<p>I absolutely agree that <em>that</em> rule isn't valid.</p>



<a name="242774182"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/negative%20impls%20integrated%20into%20coherence%20lang-team%2396/near/242774182" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/negative.20impls.20integrated.20into.20coherence.20lang-team.2396.html#242774182">(Jun 15 2021 at 18:03)</a>:</h4>
<p>To add to the "Copy stuff + String" example, this would also naturally handle things like "blanket impl for <code>Ord</code>, and specific ones for <code>f32</code> and <code>f64</code>".</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>